home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / COMM.SWG / 0004_Communications Port.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  63 lines

  1. {  >1. Let me look at the RING line from the modem
  2.   >2. Let me determine the condition of CARRIER DETECT.
  3.  
  4.  The Modem Status Register (MSR) Byte contains this info.
  5.  
  6.  Carrier Detect:  MSR bit 7 will be set it there is a carrier
  7.  detected.  Bit 3 indicates if there has been a change in the
  8.  carrier detect status since the last time the MSR was read.
  9.  
  10.  Ring:  is indicated by MSR bit 6.  Bit 2 indicates if there
  11.  was a change in bit 6 since the last time the MST was read.
  12.  
  13.  Bits 2 and 3 are cleared each time the MSR is read.
  14.  
  15.  Obtaining the MSR Byte may be done by directly reading the
  16.  port value, or by calling the BIOS modem services interrupt $14.
  17.  
  18.  I've Typed in the following without testing.
  19.  
  20.  Using the BIOS...
  21.  
  22.         ...
  23. }
  24. Function GetMSR( COMport :Byte ) :Byte;
  25. { call With COMport 1 or 2 }
  26. Var
  27.   Reg : Registers;
  28. begin
  29.   Reg.DX := COMport - 1;
  30.   Reg.AH := 3;
  31.   Intr( $14, Reg );
  32.   GetMSR := Reg.AL
  33. end;
  34. (*
  35. ...
  36. MSRByte := GetMSR(1);   { MSR For COM1 (clears bits 0..3) }
  37. ...
  38.  
  39.  Using direct access: For COM1, the MSR is at port $3FE; For COM2
  40.  it's at $2FE...
  41.  
  42.         ...
  43.         MSRByte := Port[$3FE];  { MSR For COM1 (clears bits 0..3) }
  44.         ...
  45.  
  46.  To test the status...
  47.  
  48.         ...
  49. *)
  50. IF ( MSRByte and $80 ) <> 0 then
  51.   CarrierDetect := True
  52. ELSE
  53.   CarrierDetect := False;
  54. IF ( MSRByte and $40 ) <> 0 then
  55.   Ring := True;
  56. ELSE
  57.   Ring := False;
  58. {
  59.  
  60.  Similar logic can be used With bits 2 and 3, which will inform
  61.  you of whether or not a change occurred in bit 6 or 7 since the
  62.  last read of the MSR.
  63. }